package lambda.function;

import lambda.entity.Page;

import java.util.function.BiFunction;

/**
 * @author LIBOFEI
 * @ClassName BiFunctionTest
 * @description BiFunction<T, U, R>  参数为 T，U，返回值为 R
 * @date 2022/4/6 17:08
 * @Version 1.0
 **/
public class BiFunctionTest {

    public static void main(String[] args) {
        //未使用lamda表达式之前
        Page test = test(new BiFunction<Integer, Integer, Page>() {
            @Override
            public Page apply(Integer integer, Integer integer2) {
                Page page = new Page();
                page.setPageNum(integer);
                page.setPageSize(integer2);
                return page;
            }
        });

        System.out.println(test.getPageNum() + "," + test.getPageSize());

        //使用lamda
        Page test1 = test((integer, integer2) -> {
            Page page = new Page();
            page.setPageNum(integer);
            page.setPageSize(integer2);
            return page;
        });

        System.out.println(test1.getPageNum() + "," + test1.getPageSize());
    }


    public static Page test(BiFunction<Integer,Integer,Page> userBiFunction){
        int pageNum = 1;
        int pageSize = 10;
        Page page = userBiFunction.apply(pageNum,pageSize);
        return page;
    }

}
